<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                template="./template/VisitorTemplate.xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:define name="begin">
        <f:view beforePhase="#{reservationManagerBean.init}"/>
    </ui:define>

    <ui:define name="contentInsert">   
        <h:body>
            <h:form id="formMain">

                <p:panel id="panel">
                    <p:ajaxStatus style="width:16px;height:16px;">
                        <f:facet name="start">
                            <h:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" />
                        </f:facet>
                        <f:facet name="complete">
                            <h:outputText value="" />
                        </f:facet>
                    </p:ajaxStatus>
                    <p:messages />
                    <h:panelGrid>
                        <h:outputText value="Please select date" />
                        <p:calendar value="#{reservationManagerBean.reservation.dateReserved}"/>
                        <h:outputText value="Please indicate number of people:" />
                        <p:inputText value="#{reservationManagerBean.reservation.noOfPeople}" required="true"/>
                        <p:commandButton value="Select Date" actionListener="#{reservationManagerBean.initTableList}"  update="panel" ajax="true"/>
                    </h:panelGrid>

                    <h:panelGrid id="timeslot">
                        <h:outputText value="Please select time slot:" />
                        <h:selectOneMenu value="#{reservationManagerBean.timeInput}" disabled="#{reservationManagerBean.availSlot.size() == 0}">  
                            <f:selectItems value="#{reservationManagerBean.availSlot}" />                                    
                        </h:selectOneMenu>  
                        <p:commandButton value="Generate Table" actionListener="#{reservationManagerBean.chooseTableType}" ajax="true" update="panel"/>
                    </h:panelGrid>

                    <h:panelGrid id="table" rendered="#{reservationManagerBean.createTable == true}">
                        <h:outputText value="Please select table type:" />
                        <p:dataTable id="test" var="table" value="#{reservationManagerBean.tableList}" 
                                     rowIndexVar="row" >
                            <p:column headerText="Name">
                                <h:outputText value="#{table.name}" />
                            </p:column>

                            <p:column headerText="Description">
                                <h:outputText value="#{table.description}" />
                            </p:column>
                            <p:column headerText="Picture">
                                <h:graphicImage id="gi" alt="The image could not be found."   value="/images/#{table.imageURL}" width="250" height="250"></h:graphicImage>
                            </p:column>
                            <p:column headerText="Number of seats">
                                <h:outputText value="#{table.unitCapacity}" />
                            </p:column>
                            <p:column headerText="Max">
                                <h:outputText value="#{reservationManagerBean.quantityAvail}"/>
                            </p:column>
                            <p:column headerText="Maximum num of table">
                                <p:inputText value="#{reservationManagerBean.index}"/>
                            </p:column>
                        </p:dataTable>                       
                    </h:panelGrid>  
                </p:panel>
                <p:commandButton id="btn" value="Book without meal" actionListener="#{reservationManagerBean.confirmTableTypeWithoutMeal}" update="panel" ajax="true"/>
                <p:commandButton id="btn1" value="Book with meal" actionListener="#{reservationManagerBean.confirmTableTypeWithMeal}" update="panel" ajax="true"/>

            </h:form>
        </h:body>
    </ui:define>
</ui:composition>